<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>百度</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div>

    <div style="margin-left: 1455px;margin-top: 10px">
        <button>新闻</button>&nbsp;&nbsp;
        <button>hao123</button>&nbsp;&nbsp;
        <button>地图</button>&nbsp;&nbsp;
        <button>视频</button>&nbsp;&nbsp;
        <button>贴吧</button>&nbsp;&nbsp;&nbsp;
        <button>学术</button>&nbsp;&nbsp;
        <button  data-toggle="modal" data-target="#myModal">注册</button>&nbsp;
        <button>设置</button>&nbsp;&nbsp;
    </div>
    <div style="margin-left: 800px ;margin-top: 200px ;color: aqua">
        <h1><img src="${bp}/static/images/baidu.jpg"></h1><br>
    </div>
    <div style="margin-left: 600px ;margin-top: 10px">
        <input type="text" style = "width: 640px ;height: 38px" id="city">
        <button onclick="tianqi()" style="width: 100px;height: 38px">百度一下</button>
    </div>

</div>



<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加用户
                </h4>
            </div>
            <div class="modal-body">
                用户名：<input type="text" id="username"><br>
                密&nbsp;&nbsp;&nbsp;码：<input type="password" id="password"><br>
            </div>
            <div class="modal-footer">
                <button onclick="login()" type="button" class="btn btn-primary">
                    登录
                </button>

                <button onclick="add()" type="button" class="btn btn-primary">
                    注册
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>

<script type="text/javascript">
    function login() {
        // var username =  document.getElementById("username").value
        // var password =  document.getElementById("password").value
        var username = $("#username").val()
        var password = $("#password").val()
        if(username == "" || username.length == 0){
            alert("请输入用户名")
        }
        if(password == "" || password.length == 0){
            alert("请输入密码")
        }
        if(username == "蔺玉杰" && password == "123456"){

            window.location="/user/select"
        }else{
            alert("登陆失败")

        }
    }

    function tianqi() {
            window.location="/user/select"

    }
    function add() {
        var username = $("#username").val()
        var password = $("#password").val()
        $.ajax({
            type:"post",
            url:"${bp}/user/insert",
            data:{"username":username,"password":password},
            success : function (msg) {
                if(msg == 1){
                    alert("注册成功")
                }else{
                    alert("注册失败")
                }
            }
        })
    }



    // var person = {
    //     id : 1,
    //     username: "jiege",
    //     password: "123456",
    //     fullName : function () {
    //         return this.username + "\t" + this.password
    //     }
    // }

</script>
</html>

